package com.taptech.doufu.weex.module;

import android.os.Build;
import android.view.WindowManager;

import com.taobao.weex.annotation.JSMethod;
import com.taobao.weex.common.WXModule;
import com.taptech.doufu.ui.activity.weex.TFWXActivity;
import com.taptech.doufu.weex.statusbar.StatusBarCompatFlavorRom;

/**
 * Created by Wyatt on 2017/6/16/016.
 */

public class TFStatusBarModule extends WXModule {

    @JSMethod
    public void hide(){
        try {
            TFWXActivity activity = (TFWXActivity ) mWXSDKInstance.getContext();
            activity.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        } catch (NullPointerException e) {

        }
    }

    @JSMethod
    public void show() {
        try {
            TFWXActivity activity = (TFWXActivity ) mWXSDKInstance.getContext();
            activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); //显示状态栏
            if(Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT){
                this.hide();
            }
        } catch (NullPointerException e) {

        }
    }

    @JSMethod
    public void showBlack() {
        try {
            this.show();
            TFWXActivity activity = (TFWXActivity ) mWXSDKInstance.getContext();
            StatusBarCompatFlavorRom.setLightStatusBar(activity, true);
        }catch (Exception e){
            e.printStackTrace();
        }
    }

    @JSMethod
    public void showWhite() {

        try {
            this.show();
            TFWXActivity activity = (TFWXActivity) mWXSDKInstance.getContext();
            StatusBarCompatFlavorRom.setLightStatusBar(activity, false);
        }catch (Exception e){
            e.printStackTrace();
        }
    }

    @JSMethod
    public void showImageBg() {
        try {
            this.show();
            TFWXActivity activity = (TFWXActivity) mWXSDKInstance.getContext();
            StatusBarCompatFlavorRom.setLightStatusBar(activity,false, false);
        }catch (Exception e){
            e.printStackTrace();
        }
    }

    @JSMethod
    public void setColor(String color) {

    }

}
